package com.medisched.medisched.controller;

import com.medisched.medisched.domain.Message;
import com.medisched.medisched.service.IMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 消息Controller
 * 
 * @author ruoyi
 * @date 2025-05-15
 */
@CrossOrigin
@RestController
@RequestMapping("/system/message")
public class MessageController 
{
    @Autowired
    private IMessageService messageService;

    /**
     * 查询消息列表
     */
    @GetMapping("/list")
    public List<Message>  list(Message message)
    {
        List<Message> list = messageService.selectMessageList(message);
        return list;
    }

    /**
     * 获取消息详细信息
     */
    @GetMapping(value = "/{id}")
    public Message getInfo(@PathVariable("id") Long id)
    {
        return messageService.selectMessageById(id);
    }

    /**
     * 新增消息
     */
    @PostMapping
    public int add(@RequestBody Message message)
    {
        return messageService.insertMessage(message);
    }

    /**
     * 修改消息
     */
    @PutMapping
    public int edit(@RequestBody Message message)
    {
        return messageService.updateMessage(message);
    }

    /**
     * 删除消息
     */
	@DeleteMapping("/{ids}")
    public int remove(@PathVariable Long[] ids)
    {
        return messageService.deleteMessageByIds(ids);
    }
}
